import request from '@/utils/request';

/**
 * 店铺管理API
 */

// 获取店铺列表
export function getShopList(params) {
  // 转换分页参数
  const { page, pageSize, ...otherParams } = params || {}
  const queryParams = {
    skip: page ? (page - 1) * pageSize : 0,
    limit: pageSize || 10,
    ...otherParams
  }
  return request({
    url: '/api/shop/',
    method: 'get',
    params: queryParams
  });
}

// 获取店铺统计信息
export function getShopStats() {
  return request({
    url: '/api/config/shops-stats',
    method: 'get'
  });
}

// 获取店铺详情
export function getShopDetail(id) {
  return request({
    url: `/api/shop/${id}/`,
    method: 'get'
  });
}

// 创建店铺
export function createShop(data) {
  return request({
    url: '/api/shop/',
    method: 'post',
    data
  });
}

// 更新店铺
export function updateShop(id, data) {
  return request({
    url: `/api/shop/${id}/`,
    method: 'put',
    data
  });
}

// 删除店铺
export function deleteShop(id) {
  return request({
    url: `/api/shop/${id}/`,
    method: 'delete'
  });
}

// 批量创建店铺
export function bulkCreateShops(data) {
  return request({
    url: '/api/config/shops/bulk',
    method: 'post',
    data
  });
}

// 批量更新店铺状态
export function bulkUpdateShopStatus(data) {
  return request({
    url: '/api/config/shops/bulk/status',
    method: 'put',
    data
  });
}

// 批量删除店铺
export function bulkDeleteShops(data) {
  return request({
    url: '/api/config/shops/bulk',
    method: 'delete',
    data
  });
}

/**
 * 商品相关API
 */

// 获取商品列表
export function getProductList(params) {
  return request({
    url: '/api/shop/products/',
    method: 'get',
    params
  });
}

// 获取指定店铺的所有商品
export function getShopProducts(shopId) {
  return request({
    url: `/api/shop/${shopId}/products/`,
    method: 'get'
  });
} 